package com.ruoyi.nmy.controller;


import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.nmy.domain.Transaction;
import com.ruoyi.nmy.service.ITransactionService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;


/**
 * 测试红冲列表Controller
 * 
 * @author ruoyi
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/transaction")
public class TransactionController extends BaseController {
    @Autowired
    private ITransactionService transactionService;

    /**
     * 查询测试红冲列表列表
     */
    @RequiresPermissions("nmy:transaction:list")
    @GetMapping("/list")
    public TableDataInfo list(Transaction transaction) {
        startPage();
        List<Transaction> list = transactionService.selectTransactionList(transaction);
        return getDataTable(list);
    }

    /**
     * 导出测试红冲列表列表
     */
    @RequiresPermissions("nmy:transaction:export")
    @Log(title = "测试红冲列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Transaction transaction) {
        List<Transaction> list = transactionService.selectTransactionList(transaction);
        ExcelUtil<Transaction> util = new ExcelUtil<Transaction>(Transaction.class);
        util.exportExcel(response, list, "测试红冲列表数据");
    }

    /**
     * 获取测试红冲列表详细信息
     */
    @RequiresPermissions("nmy:transaction:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(transactionService.selectTransactionById(id));
    }

    /**
     * 新增测试红冲列表
     */
    @RequiresPermissions("nmy:transaction:add")
    @Log(title = "测试红冲列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Transaction transaction) {
        return toAjax(transactionService.insertTransaction(transaction));
    }

    /**
     * 修改测试红冲列表
     */
    @RequiresPermissions("nmy:transaction:edit")
    @Log(title = "测试红冲列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody Transaction transaction) {
        transactionService.updateTransaction(transaction);
        return AjaxResult.success();
    }



    /**
     * 删除测试红冲列表
     */
    @RequiresPermissions("nmy:transaction:remove")
    @Log(title = "测试红冲列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {

        return toAjax(transactionService.deleteTransactionByIds(ids));
    }



    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response) throws Exception {
        ExcelUtil<Transaction> util = new ExcelUtil<>(Transaction.class);
        util.importTemplateExcel(response, "五险一金数据");
    }

}
